import math
from matplotlib import pyplot as plt
import numpy as np

#定义图像和三维格式坐标轴
#fig = plt.figure()
#plt.plot(X,Y)

fig, axes = plt.subplots()

x = np.arange(0, 8, 0.1)

FMGRe_256 = [152028,
             9026.82,
             976.116,
             113.839,
             13.8762,
             1.7684,
             0.236983,
             0.0404,
             0.00746916]
VCRe_256 = [152028,
            10135.4,
            1719.14,
            275.203,
            44.0969,
            7.14264,
            1.17096,
            0.194138,
            0.0325123]
itern = [0,1,2,3,4,5,6,7,8]
FMGL_256 = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
VCL_256 = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
for i in range(9):
    FMGL_256[i] = math.log(FMGRe_256[i],2)
    VCL_256[i] = math.log(VCRe_256[i],2)

y1 = -x+VCL_256[0]
y2 = -2*x+VCL_256[0]
y3 = -3*x+VCL_256[0]
y4 = -4*x+VCL_256[0]
#Y = [0.00346234,0.000897821,0.000226532, 5.67639e-05]
#Z = [ 0.0340298, 0.0171812, 0.00861096, 0.00430801]
#K = [0.00767633,0.00195667, 0.000491919, 0.000123099]

axes.set_xlabel('iter number')  # 横轴名称
axes.set_ylabel('log_residual')
#axes.set_title('Omega')  # 图形名称

#axes.plot(x, y1)
axes.plot(x, y2)
axes.plot(x, y3)
axes.plot(x, y4)
#axes.legend(["1log2", "2log2","3log2","4log2"], loc=0)
axes.plot(itern, VCL_256)
axes.scatter(itern, VCL_256, s=10, c = "black")
axes.plot(itern, FMGL_256)
axes.scatter(itern, FMGL_256, s = 10, c = "black")
#axes.legend(["VC", " ","FMG"," "], loc=1)
axes.legend(["2log2","3log2","4log2","VC", " ", "FMG", " "], loc=0)
plt.draw()
plt.savefig('re256.png')
plt.show()
